import modelExtend from 'dva-model-extend'
import { pageModel } from '@/common/model/BaseModel'
import { getList } from '../services/index'

export default modelExtend(pageModel, {
  namespace: 'propCheckTable',
  state: {
    currentItem: {},
    // searchForm values
    formValues: {},
  },
  effects: {
    *fetchList({ payload }, { call, put }) {
      console.log('fetchList')
      const res = yield call(getList, payload || {})
      yield put({
        type: 'updateState',
        payload: {
          list: res.data.data,
          pagination: {
            showSizeChanger: false,
            showQuickJumper: true,
            showTotal: total => `共 ${total} 条`,
            total: res.data.resourceSize,
            current: res.data.current,
            pageSize: res.data.size,
          },
          formValues: payload,
        },
      })
    },

    // *edit({ payload }, { call, put }) {
    //   //
    //   const res = yield call(getPropDetail, payload)
    //   if (res && res.success) {
    //     yield put({
    //       type: 'updateState',
    //       payload: {
    //         currentItem: res.data,
    //       },
    //     })
    //     yield put(
    //       routerRedux.push({
    //         pathname: '/property/update',
    //       }),
    //     )
    //   }
    // },
  },
})
